package com.spelet;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;

public class GamePreferences {
	public static final int levels = 9;
	public static Preferences prefs;
	public static boolean[] unlocked;
	public static void initiate() {
		prefs = Gdx.app.getPreferences("unlockedlevels");
		unlocked = new boolean[levels];
		if (!GamePreferences.prefs.contains(Integer.toString(0))) {
			GamePreferences.prefs.putBoolean(Integer.toString(0),true);
		}
		unlocked[0] = true;
		for (int i = 1; i < unlocked.length;i++) {
			String str = Integer.toString(i);
			if (!GamePreferences.prefs.contains(str)) {
				GamePreferences.prefs.putBoolean(str,false);
			}
			unlocked[i] = GamePreferences.prefs.getBoolean(str);
		}
		GamePreferences.prefs.flush();
	}
	public static void unlockLevel(int level) {
		unlocked[level] = true;
		prefs.putBoolean(Integer.toString(level), true);
		prefs.flush();
	}
}

